package com.ruoyi.system.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ruoyi.system.domain.BsStrategy;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 攻略游记Mapper接口
 *
 * @author ruoyi
 * @date 2023-11-25
 */
public interface BsStrategyMapper extends BaseMapper<BsStrategy> {

//    @Select("select str.*\n" +
//            "from bs_relation main\n" +
//            "         inner join bs_strategy str on main.aim_id = str.create_by_id\n" +
//            "where main.type = #{type}\n" +
//            "  and main.create_by_id = #{userId} AND main.del_flag='0' AND str.del_flag='0' and str.audit_status='1' order by str.audit_time desc ")
    List<BsStrategy> selectListByRelationAttention(@Param("userId") Long userId, @Param("type") String type, @Param("title") String title);

//    @Select("select str.*, count(main.aim_id) strategyCollectNum\n" +
//            "from bs_relation main\n" +
//            "         inner join bs_strategy str on main.aim_id = str.id\n" +
//            "where main.type = 'strategy_collect'\n" +
//            "AND main.del_flag='0' AND str.del_flag='0' and str.audit_status='1'\n" +
//            "group by main.aim_id\n" +
//            "order by strategyCollectNum desc ")
    List<BsStrategy> selectListByCollectTotal(@Param("title") String title);

    @Select("select str.*\n" +
            "from bs_relation main\n" +
            "         inner join bs_strategy str on main.aim_id = str.id\n" +
            "where main.type = #{type}\n" +
            "  and main.create_by_id = #{userId} AND main.del_flag='0' AND str.del_flag='0' and str.audit_status='1' order by str.audit_time desc ")
    List<BsStrategy> selectListByRelation(@Param("userId") Long userId, @Param("type") String type);
}
